﻿<Window x:Class="MicroBlogClient.PictureViewer"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:Rabbit.Controls;assembly=Rabbit.Controls"
        WindowStyle="None" AllowsTransparency="True" Background="{x:Null}" ShowInTaskbar="True"
        x:Name="window"  SizeToContent="WidthAndHeight"  Height="125"  Width="220"  
        MouseLeftButtonUp="window_MouseLeftButtonUp"  PreviewMouseLeftButtonDown="Canvas_PreviewMouseLeftButtonDown"
        PreviewKeyDown="myImage_PreviewKeyDown" Icon="/Resources/logo.ico" 
        PreviewKeyUp="window_PreviewKeyUp" PreviewMouseDoubleClick="window_PreviewMouseDoubleClick"  PreviewMouseRightButtonUp="Close"
        Title="{StaticResource ResourceKey=AppTitle}">
    <Grid>
        <Border BorderThickness="8" Padding="8" Panel.ZIndex="1">
            <Border.BorderBrush>
                <SolidColorBrush Opacity="0.3" Color="Black"/>
            </Border.BorderBrush>
        </Border>
        <Border CornerRadius="3" BorderThickness="1" Padding="8">
            <Border.BorderBrush>
                <SolidColorBrush Opacity="0.2" Color="Black"/>
            </Border.BorderBrush>
            <Border.Background>
                <SolidColorBrush Opacity="0.3" Color="Black"/>
            </Border.Background>
            <Grid>
                <Canvas Grid.Row="0" Style="{DynamicResource PictureViewerTitleBar}"
                     Visibility="{Binding ElementName=window,Path=IsMouseOver,Converter={StaticResource BooleanToVisibilityConverter}}"
                   VerticalAlignment="Top">
                    <TextBlock Style="{DynamicResource PictureViewerFunctionTextStyle}" Canvas.Left="5" PreviewMouseLeftButtonUp="ZoomIn_PreviewMouseLeftButtonUp">放大</TextBlock>
                    <TextBlock Style="{DynamicResource PictureViewerFunctionTextStyle}" Canvas.Left="30" PreviewMouseLeftButtonUp="ZoomOut_PreviewMouseLeftButtonUp">缩小</TextBlock>
                    <TextBlock Style="{DynamicResource PictureViewerFunctionTextStyle}" Canvas.Left="55" PreviewMouseLeftButtonUp="LeftRotation_PreviewMouseLeftButtonUp" >左旋</TextBlock>
                    <TextBlock Style="{DynamicResource PictureViewerFunctionTextStyle}" Canvas.Left="80" PreviewMouseLeftButtonUp="RightRotation_PreviewMouseLeftButtonUp">右旋</TextBlock>
                    <TextBlock Style="{DynamicResource PictureViewerFunctionTextStyle}" Canvas.Left="105" PreviewMouseLeftButtonUp="Recover_PreviewMouseLeftButtonUp">还原</TextBlock>
                    <TextBlock Style="{DynamicResource PictureViewerFunctionTextStyle}" Canvas.Left="135" PreviewMouseLeftButtonUp="Save_PreviewMouseLeftButtonUp">保存</TextBlock>
                    <TextBlock Style="{DynamicResource PictureViewerFunctionTextStyle}" Canvas.Right="9" PreviewMouseLeftButtonUp="Close">X</TextBlock>
                </Canvas>

                <Border  HorizontalAlignment="Center" x:Name="LoadingBorder" Padding="15" Height="75"  Width="190"  CornerRadius="5"  VerticalAlignment="Center">
                    <Border.Background>
                        <SolidColorBrush Color="Black" Opacity="0.4"/>
                    </Border.Background>
                    <Border.Effect>
                        <DropShadowEffect BlurRadius="0.1" Opacity="0.1" RenderingBias="Performance"/>
                    </Border.Effect>
                    <Canvas>
                        <ProgressBar BorderThickness="0"
                                 Background="White"
                                 Canvas.Top="20" IsIndeterminate="True"
                                 Height="15"  Width="170" Opacity="1"
                                 VerticalAlignment="Center"/>
                        <TextBlock Foreground="#dddddd">图片加载中...</TextBlock>
                    </Canvas>
                </Border>
                <Canvas  MinHeight="85"  MinWidth="190" Height="{Binding Path=ActualHeight,ElementName=myImage}" Width="{Binding Path=ActualWidth,ElementName=myImage}">
                    <controls:ImageEx Stretch="Fill"   ToolTip="鼠标滚动调整图片大小，双击还原,右键关闭"
                                    x:Name="myImage" PreviewKeyDown="myImage_PreviewKeyDown"
                                    ImageLoaded="myImage_ImageLoaded"
                                    RenderTransformOrigin="0.5,0.5" Canvas.Left="0" Canvas.Top="0"
                                    MouseWheel="myImage_MouseWheel"  SizeChanged="myImage_SizeChanged"
                                    Source="{Binding PictureSource}"  
                                    MouseMove="myImage_MouseMove"  
                                    MouseLeftButtonDown="myImage_MouseLeftButtonDown">
                        <controls:ImageEx.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform x:Name="imgScaleTransform"/>
                                <RotateTransform x:Name="imgRotateTransform"/>
                            </TransformGroup>
                        </controls:ImageEx.RenderTransform>
                    </controls:ImageEx> 
                </Canvas>
            </Grid>
        </Border>
    </Grid>
</Window>
